package com.jcl.recruit.crawler.dao;

import com.jcl.core.db.DatabaseContext;
import com.jcl.recruit.crawler.mapper.CrawlerDownloadTaskMapper;
import com.jcl.recruit.crawler.model.CrawlerDownloadTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

@Component
public class CrawlerDownloadTaskDao implements CrawlerDownloadTaskMapper {

    @Autowired
    private CrawlerDownloadTaskMapper crawlerDownloadTaskMapper;

    @Override
    public List<CrawlerDownloadTask> findListByDown(String corpCode,
                                                    String channelType,
                                                    Integer... statusList) {
        DatabaseContext.setCurrentContext();
        return crawlerDownloadTaskMapper.findListByDown(corpCode, channelType, statusList);
    }

    @Override
    public List<CrawlerDownloadTask> findList(String corpCode,
                                              String channelType,
                                              Integer resumeId,
                                              Integer status) {
        DatabaseContext.setCurrentContext();
        return crawlerDownloadTaskMapper.findList(corpCode, channelType, resumeId, status);
    }

    @Override
    public List<CrawlerDownloadTask> findResumeListByUser(String corpCode,
                                                          Integer userId) {
        DatabaseContext.setCurrentContext();
        return crawlerDownloadTaskMapper.findResumeListByUser(corpCode, userId);
    }

    @Override
    public List<CrawlerDownloadTask> findResumeListByUserIds(String corpCode,
                                                             List<Integer> userIds) {
        DatabaseContext.setCurrentContext();
        return crawlerDownloadTaskMapper.findResumeListByUserIds(corpCode, userIds);
    }

    @Override
    public int add(CrawlerDownloadTask crawlerDownloadTask) {
        DatabaseContext.setCurrentContext();
        return crawlerDownloadTaskMapper.add(crawlerDownloadTask);
    }

    @Override
    public int updateByResumeIds(List<Integer> resumeIds, Integer status) {
        DatabaseContext.setCurrentContext();
        return crawlerDownloadTaskMapper.update(resumeIds, status);
    }

    @Override
    public int update(List<Integer> ids,
                      Integer status) {
        DatabaseContext.setCurrentContext();
        return crawlerDownloadTaskMapper.update(ids, status);
    }

    @Override
    public int updateTimer(String date,
                           Integer status,
                           String corpCode,
                           String resumeId) {
        DatabaseContext.setCurrentContext();
        return crawlerDownloadTaskMapper.updateTimer(date, status, corpCode, resumeId);
    }
}
